{%include file="header.html"%}
<style>
th{ text-align:left;}
</style>
<body>
<div class="fixed-bar">
  <div class="item-title">
    <h3>商品类型</h3>
    <div style="background:rgba(251,112,45,1);width:125px;height:40px;float:right;text-align:center;border-radius:5px;">
      <a href="attribute.php?act=edit&goods_type={%$goods_type%}">
        <h5 style="padding:10px;color:#fff;">添加属性</h5>
      </a>
    </div>
  </div>
</div>
<div class="fixed_bottom">
  <form method="post" action="" id="aspnetForm" name="form1">
    <table align="center;" class="table tb-type2">
      <thead>
        <tr>
          <th width="50"><a>编号</a></th>
          <th width="25%"><a>属性名称</a></th>
          <th><a>商品类型</a></th>
          <th><a>可选值列表</a></th>
          <th><a>排序</a></th>
          <th width="10%"><a>操作</a></th>
        </tr>
      </thead>
      <tbody>
      	{%foreach from=$info item=list%}
      	<tr class="par_{%$list.parent_id%}">
          <td>{%$list.attr_id%}</td>
          <td>{%$list.attr_name%}</td>
          <td>{%$list.cat_name%}</td>
          <td>{%$list.attr_values%}</td>
          <td>{%$list.sort_order%}</td>
          <td><a href="attribute.php?act=edit&id={%$list.attr_id%}">编辑</a> | <span onclick="ajax_del(this,{%$list.attr_id%})" style="cursor:pointer;">删除</span></td>
        </tr>
        {%/foreach%}
      
    </table>
  </form>
</div>
</body>
<script>
//删除属性
function ajax_del(obj,id){
    $.post("attribute.php",{act:'del_judge',attr_id:id},function(data){
        if(data>0){
              var msg = "已经有"+data+"个商品使用该属性，您确实要删除该属性吗？";
        }else{
              var msg = "您确实要删除该属性吗？";
        }
        layer.confirm(msg, {
        btn: ['确认','取消'] //按钮
        }, function(){
            $.post("attribute.php",{act:'ajax_del',attr_id:id},function(data){
                if(data==1){
                    $(obj).parent().parent().remove();
                    layer.msg("操作成功! ");
                }else if(data==2){
                    layer.msg("操作失败! ");
                }
            });     
        }, function(){
           layer.msg('明白了', {
           time: 1000//20s后自动关闭
        });
    });
      });
}
</script>
</html>